import Vue from 'vue'
//引入路由插件
import VueRouter from 'vue-router'
//加载首页,首页不需要懒加载
import movie from '../views/home/movie.vue'

//使用路由插件
Vue.use(VueRouter)
//定义路由表
const routes = [
  //重定向
  { path: "/", redirect: "/hot" },
  {
    path: '/',
    name: 'movie',
    component: movie,
    //配置子路由
    children: [
      { path: "hot", name: "hot", component: () => import(/* webpackChunkName: "hot" */ '../views/home/hot.vue') },
      { path: "cinema", name: "cinema", component: () => import(/* webpackChunkName: "cinema" */ '../views/home/cinema.vue') },
      { path: "wait", name: "wait", component: () => import(/* webpackChunkName: "wait" */ '../views/home/wait.vue') },
      { path: "classic", name: "classic", component: () => import(/* webpackChunkName: "classic" */ '../views/home/classic.vue') }
    ]
  },
  {
    path: '/myvideo',
    name: 'myvideo',
    //路由懒加载，路由到哪个页面就加载哪个页面的组件，优化性能，可以使首页加载速度变快
    component: () => import(/* webpackChunkName: "myvideo" */ '../views/myvideo.vue')
  },
  {
    path: '/shortvideo',
    name: 'shortvideo',
    component: () => import(/* webpackChunkName: "video" */ '../views/shortvideo.vue')
  },
  {
    path: '/show',
    name: 'show',
    component: () => import(/* webpackChunkName: "video" */ '../views/show.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "video" */ '../views/login.vue')
  },
  //item的路由,动态路由
  {
    path: '/item/:id',
    name: 'item',
    component: () => import(/* webpackChunkName: "item" */ '../views/item.vue')
 },
]
//创建路由实例
const router = new VueRouter({
  routes
})

export default router
